package main

import "fmt"

type Student struct {
	id    int
	name  string
	age   int
	sex   string
	score int
	addr  string
}

func Sort(arr [5]Student) {
	for i:=0;i<len(arr) -1;i++{
		for j:=0;j<len(arr) -i-1;j++{
			if arr[j].age > arr[j+1].age{
				arr[j],arr[j+1] = arr[j+1],arr[j]
			}
		}
	}
	fmt.Println(arr)
}
func main() {
	var arr [5] Student = [5] Student{
		{101, "唐三藏", 32, "男", 100, "东土大唐"},
		{102, "孙悟空", 532, "男", 100, "花果山"},
		{101, "猪八戒", 600, "男", 100, "高老庄"},
		{101, "沙悟净", 180, "男", 100, "流沙河"},
		{101, "白龙马", 10, "男", 100, "西海"},
	}
	//fmt.Println(arr)
	// 结构体数组作为函数参数是值传递
	// 结构体切片作为函数参数是地址传递
	Sort(arr)
}
